package com.peixunp.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.peixunp.bean.Place;
import com.peixunp.service.OrganizationsService;
import com.peixunp.service.PlaceService;

import finaler.util.Page;
import finaler.util.PageList;

@Controller
@RequestMapping("city")
public class CityController {

	@Autowired
	private PlaceService placeService;
	
	@Autowired
	private OrganizationsService organizationsService;
	
	@RequestMapping( value="/{cityId}.html" )
	public String chooseCity(@PathVariable int cityId,HttpServletRequest request) throws Exception {
		Place city  = placeService.findByKey(cityId);
		request.setAttribute("city", city);
		Page page = new Page(request);
		page.putParameter("cityId", cityId);
		PageList schoolList = organizationsService.getOrgList(page);
		request.setAttribute("schoolList", schoolList);
		return "/school/city";
	}
	

}
